package com.sangmo.fts.training.model;

import com.sangmo.boot.framework.data.entity.general.AuditEntity;
import com.sangmo.boot.framework.data.entity.general.SoftDeleteEntity;
import com.sangmo.boot.framework.data.json.meta.ExtView;
import com.sangmo.boot.framework.data.json.meta.Formula;
import com.sangmo.boot.framework.data.json.meta.One;
import com.sangmo.boot.framework.plugin.dataview.def.meta.DataField;
import com.sangmo.boot.framework.plugin.dataview.def.meta.DataView;
import com.sangmo.fts.basic.model.FileUpload;
import com.sangmo.fts.clazz.model.Clazz;
import com.sangmo.fts.common.IConstants;
import com.sangmo.fts.teacher.model.Examination;
import com.sangmo.fts.training.calculator.ScoreRankingCalculator;
import com.sangmo.fts.user.model.User;

import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;

@Entity
@Table(name = "score")
@DataView
@ExtView
@Formula(value = "ranking", calc = ScoreRankingCalculator.class, groups = {"Score.search", "Score.detail"})
public class Score extends AuditEntity {

    @DataField(value = IConstants.DATA_TYPE.LONG, required = true, index = true)
    @One(value = "examination", target = Examination.class, groups = {"Score.search", "Score.detail"})
    private Long examinationId;

    @DataField(value = IConstants.DATA_TYPE.LONG, required = true, index = true)
    private Long trainingId;

    @One(value = "clazz", target = Clazz.class, groups = {"Score.search", "Score.detail"})
    @DataField(value = IConstants.DATA_TYPE.LONG, required = true, index = true)
    private Long clazzId;

    @One(value = "user", target = User.class, groups = {"Score.search", "Score.detail"})
    @DataField(value = IConstants.DATA_TYPE.LONG, required = true, index = true)
    private Long userId;

    @One(value = "reportDocument", target = FileUpload.class, groups = {"Score.search", "Score.detail"})
    private Long reportDoc;

    @DataField(value = IConstants.DATA_TYPE.DECIMAL_POSITIVE_MONEY, required = true)
    private BigDecimal processMark = BigDecimal.ZERO;

    @DataField(value = IConstants.DATA_TYPE.DECIMAL_POSITIVE_MONEY, required = true)
    private BigDecimal reportMark = BigDecimal.ZERO;

    @DataField(value = IConstants.DATA_TYPE.DECIMAL_POSITIVE_MONEY, required = true)
    private BigDecimal growthMark = BigDecimal.ZERO;

    @DataField(value = IConstants.DATA_TYPE.DECIMAL_POSITIVE_MONEY, required = true)
    private BigDecimal durationMark = BigDecimal.ZERO;

    private String state = States.PENDING;

    private BigDecimal finalMark = BigDecimal.ZERO;

    private String remark;

    public Long getExaminationId() {
        return examinationId;
    }

    public void setExaminationId(Long examinationId) {
        this.examinationId = examinationId;
    }

    public Long getTrainingId() {
        return trainingId;
    }

    public void setTrainingId(Long trainingId) {
        this.trainingId = trainingId;
    }

    public Long getClazzId() {
        return clazzId;
    }

    public void setClazzId(Long clazzId) {
        this.clazzId = clazzId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getReportDoc() {
        return reportDoc;
    }

    public void setReportDoc(Long reportDoc) {
        this.reportDoc = reportDoc;
    }

    public BigDecimal getProcessMark() {
        return processMark;
    }

    public void setProcessMark(BigDecimal processMark) {
        this.processMark = processMark;
    }

    public BigDecimal getReportMark() {
        return reportMark;
    }

    public void setReportMark(BigDecimal reportMark) {
        this.reportMark = reportMark;
    }

    public BigDecimal getGrowthMark() {
        return growthMark;
    }

    public void setGrowthMark(BigDecimal growthMark) {
        this.growthMark = growthMark;
    }

    public BigDecimal getDurationMark() {
        return durationMark;
    }

    public void setDurationMark(BigDecimal durationMark) {
        this.durationMark = durationMark;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public BigDecimal getFinalMark() {
        return finalMark;
    }

    public void setFinalMark(BigDecimal finalMark) {
        this.finalMark = finalMark;
    }

    public interface States {
        String PENDING = "PENDING"; //待评定
        String COMPLETED = "COMPLETED"; //已评定
    }

    public interface IRankingCalculator {

    }
}
